<h1>register:</h1>

<?= form_open('blog/index/', 'id="register_form"') ?>
<table>
	<tr>
		<td>username:</td>
		<td><?= form_input(array('type' => 'text', 'name' => 'user_name')) ?></td>
		<td></td>
	</tr>
	<tr>
		<td>email:</td>
		<td><?= form_input(array('type' => 'text', 'name' => 'user_email')) ?></td>
		<td></td>
	</tr>
	<tr>
		<td>role:</td>
		<td><?= form_dropdown('user_role', array('' => 'select role', '1' => 'admin', '2' => 'user'), null) ?></td>
		<td></td>
	</tr>
	<tr>
		<td>password:</td>
		<td><?= form_input(array('type' => 'password', 'name' => 'user_password', 'id' => 'user_password')) ?></td>
		<td></td>
	</tr>
	<tr>
		<td>confirm password:</td>
		<td><?= form_input(array('type' => 'password', 'name' => 'confirm_password')) ?></td>
		<td></td>
	</tr>
	<tr>
		<td></td>
		<td><?= form_submit('submit', 'submit') ?></td>
		<td></td>
	</tr>
</table>
<?= form_close() ?>

<script>
$(function(){
	$('#register_form').validate({
		rules: {
			user_name: {required:true, minlength:4},
			user_email: {required:true, email:true},
			user_role: {required:true},
			user_password: {required:true, minlength:4},
			confirm_password: {required:true, equalTo:'#user_password'}
		},
		errorPlacement: function(error, element) {
			error.insertAfter(element.parent().next());
		}
	});
});
</script>